package com.hanlp.top_interview_150.数组;


/**
 * 26. 删除有序数组中的重复项
 * https://leetcode.cn/problems/remove-duplicates-from-sorted-array/description/?envType=study-plan-v2&envId=top-interview-150
 */
public class A03 {
    public static void main(String[] args) {

    }

    public static  int removeDuplicates(int[] nums) {
        if(nums.length < 2){
            return nums.length;
        }
        int count = 0;
        for (int i = 1; i < nums.length; i++) {
            if(nums[count] != nums[i]){
                nums[++count] = nums[i];
            }
        }
        return count+1;
    }


}
